<template>
  <div class="app-container">
    <div class="inner-container">
      <el-upload
        ref="uploadExcel"
        class="upload-demo"
        :action="upLoadUrl"
        :auto-upload="true"
        :on-success="fileUploadSuccess"
      >
        <el-button size="small" type="primary" style="margin: 15px 15px">选择文件</el-button>
      </el-upload>
      <el-button type="primary" style="margin: 15px 15px" @click="downloadFile">下载文件</el-button>
    </div>
  </div>
</template>
<script>
import { $gc } from 'gc-starter-ui-plus'
export default {
  data() {
    return {
      form: {
        file: ''
      },
      upLoadUrl: '',
      fileList: []
    }
  },
  mounted() {
    this.upLoadUrl = window.SITE_CONFIG['baseUrl'] + '/file/upload?token=' + $gc.$cookie.get('token')
  },
  methods: {
    fileUploadSuccess(response, file, fileList) {
      this.$notify.success({
        title: '成功',
        message: `文件上传成功`
      })
    },
    downloadFile() {
      window.location = window.SITE_CONFIG['baseUrl'] + '/file/download'
    }
  }
}
</script>
